package com.zygh.policeasset.mapper;

import com.zygh.policeasset.pojo.Project;
import com.zygh.policeasset.pojo.UnitInformation;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/mapper/UnitInformationMapper.class */
public interface UnitInformationMapper {
    @Select({"<script>", "select u1.*,p.name as project_name,af.approval_steps_id as approvalStepsId,af.app_status,u.name as userName from unit_information u1  left join  project p on u1.project_no = p.project_no left join audit_flow af on u1.flow_no = af.flow_no left join user u on af.applicant = u.id <where><if test='projectNo != null and projectNo.length &gt; 0'>and u1.project_no = #{projectNo} </if><if test='name != null and name.length &gt; 0'>and p.name like '%${name}%' </if><if test='unitNature != null and unitNature.length &gt; 0'>and u1.unit_nature = #{unitNature} </if><if test='userId != null '> and af.applicant=#{userId} </if><if test=' status != null'> and af.app_status = #{status} </if></where>order by u1.id desc </script>"})
    @Results(id = "UnitInformationMap", value = {@Result(property = "projectNo", column = "project_no"), @Result(property = "projectName", column = "project_name"), @Result(property = "unitNature", column = "unit_nature"), @Result(property = "constructionCompany", column = "construction_company"), @Result(property = "contractAmount", column = "contract_amount"), @Result(property = "bidAmount", column = "bid_amount"), @Result(property = "entrustAmount", column = "entrust_amount"), @Result(property = "contractInfo", column = "contract_info"), @Result(property = "rate", column = "rate"), @Result(property = "designAmount", column = "design_amount"), @Result(property = "remark", column = "remark"), @Result(property = "flowNo", column = "flow_no"), @Result(property = "appStatus", column = "app_status")})
    List<UnitInformation> findByProject(@Param("projectNo") String str, @Param("name") String str2,
                                        @Param("status") Integer status, @Param("unitNature") String str3,
                                        @Param("userId") Integer num);

    @Select({"<script>", "select u1.*,p.name as project_name,af.approval_steps_id as approvalStepsId,af.app_status,u.name as userName from unit_information u1  left join  project p on u1.project_no = p.project_no left join audit_flow af on u1.flow_no = af.flow_no left join user u on af.applicant = u.id <where><if test='id != null'>and u1.id = #{id} </if></where></script>"})
    @ResultMap({"UnitInformationMap"})
    UnitInformation findById(@Param("id") Integer id);

    @Select({"select p.* from project p left join audit_flow af on p.flow_no = af.flow_no where  af.app_status = 2 and p.pid !=0 order by p.id  desc "})
    @Results({@Result(property = "projectNo", column = "project_no"), @Result(property = "commissionNo", column = "commission_no"), @Result(property = "companyApply", column = "company_apply"), @Result(property = "capitalSource", column = "capital_source"), @Result(property = "projectBase", column = "project_base"), @Result(property = "startDatetime", column = "start_datetime")})
    List<Project> getAdd();

    @Insert({"insert into unit_information (project_no,unit_nature,construction_company,contract_amount,bid_amount,entrust_amount,contract_info,rate,design_amount,remark,flow_no) values (#{projectNo},#{unitNature},#{constructionCompany},#{contractAmount},#{bidAmount},#{entrustAmount},#{contractInfo},#{rate},#{designAmount},#{remark},#{flowNo})"})
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    Integer add(UnitInformation unitInformation);

    @Update({"update unit_information set project_no=#{projectNo},unit_nature=#{unitNature},construction_company=#{constructionCompany},contract_amount=#{contractAmount},bid_amount=#{bidAmount},entrust_amount=#{entrustAmount},contract_info=#{contractInfo},rate=#{rate},design_amount=#{designAmount},remark=#{remark} where id=#{id}"})
    Integer update(UnitInformation unitInformation);

    @Delete({"delete from unit_information where id=#{id}"})
    Integer remove(int i);

    @Update({"update unit_information set status=#{status} where id=#{id}"})
    Integer updateByid(@Param("id") Integer num, @Param("status") Integer num2);

    @Select({"select c.id from unit_information c"})
    List<UnitInformation> doTest();

    @Update({"update unit_information set flow_no = #{flowNo} where id=#{id}"})
    Integer updateFlowNo(@Param("flowNo") String str, @Param("id") Integer num);

    @Select({"select count(*) from unit_information where project_no = #{projectNo}"})
    Integer getProjectNoCount(String str);
}